package com.system.zuul;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

import java.awt.*;

/**
 * @author Lisiyu
 * date 2022/10/21 0:21
 * version 1.0
 */
@SpringBootApplication
@EnableZuulProxy
public class ZuulStartApp {
    public static void main(String[] args) {
        SpringApplication.run(ZuulStartApp.class,args);
    }
    /**
     * 通过一个表达式类型的对象将我们的映射规则修改为对应版本号的
     * @return
     */
    @Bean
    public PatternServiceRouteMapper serviceRouteMapper() {
        return new PatternServiceRouteMapper(
                //参数1 服务名字的规则必须是 xxxxxx-vbanben这样的
                //参数2 映射后的方式就是/vbanben/xxxxxx
                "(?<name>^.+)-(?<version>v.+$)",
                "${version}/${name}");
    }
}
